//
//  LKVisitorViewController.swift
//  LKWeibo
//
//  Created by like on 16/8/9.
//  Copyright © 2016年 like. All rights reserved.
//

import UIKit

class LKVisitorViewController: UIViewController {
    
    // 判断用户是否登录
    var isLogin: Bool = LKUserAccountViewModel.sharedTools.isLogin
    //访问视图view
    var visitorView: LKVisitorView?
    
    override func loadView() {
       
        if isLogin {
            view = tableView
            
        }else{
            
            setupVisitorView()
        }
        
    }
//创建访客视图view  添加到当前的view
    func setupVisitorView(){
        visitorView = LKVisitorView()
        //闭包 02
        visitorView?.closure = {
            //跳转到登陆注册 控制器
           self.loginAction()
            
        }
        view = visitorView
        setupNVitem()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }


    func setupNVitem(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(LKVisitorViewController.loginAction))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(LKVisitorViewController.loginAction))
    }
    

    
    func loginAction(){
        let vc = LKOAuthViewController()
        
        presentViewController(UINavigationController(rootViewController: vc), animated: true) { 
            
        }
    }

    //懒加载tableview
    lazy var tableView: UITableView = UITableView()
}
